#!/bin/sh
# ntfs-3g_static
# Builds from https://github.com/puppylinux-woof-CE/petbuilds

. ../../func

# GOES TO INITRD
URL=http://tuxera.com/opensource
SRC=ntfs-3g_ntfsprogs
PKG=ntfs-3g_static
VER=2017.3.23
COMP=tgz
DESC=""
DEPS=
CAT=BuildingBlock
CWD=`pwd`

build() {
	cd ${SRC}-${VER}
	# diff -Naur ntfs-3g_ntfsprogs-2016.2.22 ntfs-3g_ntfsprogs-2016.2.22-patched > libfuse-musl.patch
	patch -N -p1 < ../libfuse-musl.patch
	opts="--prefix=/usr --disable-library --enable-really-static --enable-mount-helper"
	_configure
	sed -i 's| -static| -all-static|' ntfsprogs/Makefile
	_make
	abort_if_file_not_found src/ntfs-3g ntfsprogs/ntfsfix
	install -d -m 0755 $CWD/${PKG}-${VER}-${ARCH}/bin
	_install src/ntfs-3g $CWD/${PKG}-${VER}-${ARCH}/bin
	_install ntfsprogs/ntfsfix $CWD/${PKG}-${VER}-${ARCH}/bin
	cd -
}

package() {
	# add this recipe
	install -d -m 0755 ./${PKG}-${VER}-${ARCH}/build
	cat ${PKG}.petbuild > ./${PKG}-${VER}-${ARCH}/build/$PKG-build-recipe
	# move, don't package
	cp -a --remove-destination ./${PKG}-${VER}-${ARCH}/* ../../00_${ARCH}
	rm -r ${SRC}-${VER}
	rm -r ${PKG}-${VER}-${ARCH}
	echo "moved to initrd"
	echo "done!"
}

# main
retrieve ${SRC}-${VER}.${COMP}
[ "$DLD_ONLY" = "yes" ] && exit
extract ${SRC}-${VER}.${COMP}
build
package
